import requests

def create_url(start_page, end_page):
    base_url = "https://www.hbjcxy.com/jyyw/"
    for i in range(start_page - 1, end_page):
        if i == 0:
            url = base_url + "index" + ".html"
            print(url)
            html = do_request(url)
            save_file(str(i), html)
        else:
            url = base_url + "index" + "_" + str(i + 1) + ".html"
            print(url)
            html = do_request(url)
            save_file(str(i), html)

def save_file(filename, html):
    with open("网页/" + filename, "w+", encoding="utf-8") as f:
        f.write(html)

def do_request(url):
    # 每个url进行请求
    response = requests.get(url)
    # 编码方式
    response.encoding = "utf-8"
    return response.text

if __name__ == '__main__':
    create_url(1, 5)
